package com.yyi.springcloud.controller;
//
//                       _oo0oo_
//                      o8888888o
//                      88" . "88
//                      (| -_- |)
//                      0\  =  /0
//                    ___/`---'\___
//                  .' \\|     |// '.
//                 / \\|||  :  |||// \
//                / _||||| -:- |||||- \
//               |   | \\\  -  /// |   |
//               | \_|  ''\---/''  |_/ |
//               \  .-\__  '-'  ___/-. /
//             ___'. .'  /--.--\  `. .'___
//          ."" '<  `.___\_<|>_/___.' >' "".
//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |
//         \  \ `_.   \_ __\ /__ _/   .-` /  /
//     =====`-.____`.___ \_____/___.-`___.-'=====
//                       `=---='
//
//
//     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//               佛祖保佑         永无BUG
//

import com.yyi.springcloud.common.PageInfoResult;
import com.yyi.springcloud.entities.SensorInfoModel;
import com.yyi.springcloud.entities.TestDataVo;
import com.yyi.springcloud.service.DataListService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author: yyi
 * @date: 2019/7/12 18:34
 * @parameters:
 * @desc:
 **/
@RestController
@RequestMapping("/consumer/dataListAPI")
public class DataListController {
    private Logger logger = LoggerFactory.getLogger(DataListController.class);
    private static final String REST_URL_PREFIX = "http://MICROSERVICECLOUD-DEPT";
    @Autowired
    private DataListService dataListService;
    //获取所有传感器名称
    //http://localhost/consumer/dataListAPI/getAllSelectSensorName?primaryKey=2017-11-1611:17:211&testunitno=1
    @CrossOrigin
    @RequestMapping(value = "/getAllSelectSensorName",method = RequestMethod.GET)
    public List<SensorInfoModel> getAllSelectSensorName(HttpServletRequest request){
        String primaryKey = request.getParameter("primaryKey");
        String testunitno = request.getParameter("testunitno");
       return dataListService.getAllSelectSensorName(primaryKey,testunitno);
    }
    //获取所有的传感参数信息
    //http://localhost/consumer/dataListAPI/getAllTestDataVo?labcode=Haierrefrigerator20151214&testunitno=1
    @CrossOrigin
    @RequestMapping(value = "/getAllTestDataVo", method = RequestMethod.GET)
    public PageInfoResult<TestDataVo> getAllTestDataVo(HttpServletRequest request){
        String labcode = request.getParameter("labcode");
        String testunitno = request.getParameter("testunitno");
        String startdate = request.getParameter("startdate");// 开始时间
        String enddate = request.getParameter("enddate");// 结束时间
        String pageNum = request.getParameter("pageNum");
        String pageSize = request.getParameter("pageSize");
        return dataListService.getAllTestDataVo(labcode,testunitno,startdate,enddate,pageNum,pageSize);
    }
}
